/*
 * Copyright (C) 拾光分享网 
 * All rights reserved, Designed By www.hiai.top.
 * Email：goodsking@163.com.
 * Version：V1.0.2(20230701).
 */
package top.hiai._admin.words;

import com.jfinal.kit.Ret;
import com.jfinal.plugin.activerecord.Page;

import top.hiai.common.model.Words;
import top.hiai.config.BaseController;

/**
* @Author www.hiai.top
* @Email  goodsking@163.com
* @Message 更多资源尽在www.hiai.top
* @Introduction 类的介绍
*/

public class WordsAdminController extends BaseController{

	WordsAdminService wordsAdminService = WordsAdminService.me;

	/**
	 * 后台文章管理主页面
	 */
	public void index() {
		Page<Words> wordsPage = wordsAdminService.paginate(getParaToInt("p", 1),limtCount);
		setAttr("wordsPage", wordsPage);
		render("wordsList.html");
	}
	
	/**
	 * 根据分类ID查找
	 */
	public void findById(){
		Words words = wordsAdminService.findById(getParaToInt("id"));
		renderJson("result",words);
	}
	
	/**
	 * 添加敏感词
	 */
	public void wordsAdd(){
		Boolean result = wordsAdminService.wordsAdd(get("word"),getInt("status"), get("word_pinyin"));
		renderJson("success",result);
	}
	
	/**
	 * 修改敏感词
	 */
	public void wordsEdit(){
		Boolean result = wordsAdminService.wordsEdit(getInt("id"),get("word"),getInt("status"), get("word_pinyin"));
		renderJson("success",result);
	}
	
	/**
	 * 删除敏感词
	 */
	public void wordsDelete(){
		wordsAdminService.wordsDelete(getInt("id"));
		redirect("/admin/words");
	}
	
	/**
	 * 敏感词启动
	 */
	public void lock() {
		Ret ret = wordsAdminService.lock(getParaToInt("id"));
		renderJson(ret);
	}

	/**
	 * 解锁
	 */
	public void unlock() {
		Ret ret = wordsAdminService.unlock(getParaToInt("id"));
		renderJson(ret);
	}
}